package com.example.demo;

/**
 * @author wenl
 * @version V2.0
 * @project education
 * @package com.example.demo
 * @date 2020/4/7
 * @describe
 */
public class ThreadLocalTest {
    static ThreadLocal<User> tl = new ThreadLocal<>();

    public static void main(String[] args) {
        tl.set(new User(1,"小明1"));
        tl.set(new User(2,"小明2"));
        tl.set(new User(3,"小明3"));

        ThreadLocalTest tlt = new ThreadLocalTest();
        tlt.step1();
        tlt.step2();
    }

    void step1() {
        User u = tl.get();
        log();
        System.out.println(u);
//        printUser();
    }

    void log() {
        User u = tl.get();
//        println(u.name);
        System.out.println(u);
    }

    void step2() {
        User u = tl.get();
//        checkUser(u.id);
        System.out.println(u);

    }

}
